package util;

import jakarta.servlet.http.HttpSession; // 修改为 jakarta

public class SessionUtils {
    public static Integer getUserId(HttpSession session) {
        if (session == null) {
            return null;
        }
        Object userIdObj = session.getAttribute("userId");
        if (userIdObj instanceof Integer) {
            return (Integer) userIdObj;
        }
        return null;
    }

    public static void setUserId(HttpSession session, Integer userId) {
        if (session != null) {
            session.setAttribute("userId", userId);
        }
    }
}